<?php

namespace app\shop\controller;
use icontroller\admin\AController;
use logic\admin\shop\LShopStore;


class ShopStore extends AController {

    private $logic;
    function __construct()
    {
        parent::__construct();
        $this->logic=new LShopStore();
    }

    public function index() {
        return view();
    }

    // <editor-fold defaultstate="collapsed" desc="选择位置">
    public function position(){
        return view();
    }
    // </editor-fold>

    public function index_data(){
        $param=array(
            'search'=>input('search'),
            'limit'=>input('limit'),
            'offset'=>input('offset'),
            'sort'=>input('sort'),
            'order'=>input('order'),
            'status'=>input('status'),
            'begindate'=>input('begindate'),
            'enddate'=>input('enddate'),
        );

        $data=$this->logic->index_data($param);
        return $data;
    }

    function add()
    {
        $account_list = $this->logic->account_data();
        $this->assign('data',$account_list);
        return view();
    }

    function insert()
    {
        $param=array(
            'name'=>input('name'),
            'province'=>input('province'),
            'city'=>input('city'),
            'district'=>input('district'),
            'shop_address'=>input('shop_address'),
            'longitude'=>input('longitude',0),
            'latitude'=>input('latitude',0),
            'summary'=>input('summary'),
            'zoom'=>input('zoom'),
            'mobile'=>input('mobile'),
            'cover_image'=>input('cover_image'),
            'logo'=>input('logo'),
            'bizhours_start'=>input('bizhours_start'),//营业时间开始
            'bizhours_end'=>input('bizhours_end'),//营业时间结束
            'flag_lock'=>input('flag_lock'),
            'aps_price' => input('aps_price'),
            'is_recommended'=>input('is_recommended')
        );
        $data=$this->logic->insert_data($param);
        return $data;
    }

    function edit()
    {
        $id=input('id');
        $data=$this->logic->edit_data($id);
        //print_r($data);die();
//        $account_list = $this->logic->account_data();
//
//        $this->assign('account_data',$account_list);
        $this->assign('data',$data);
        return view();
    }

    function update()
    {
        $id=input('id');
        $param=array(
            'name'=>input('name'),
            'province'=>input('province'),
            'city'=>input('city'),
            'district'=>input('district'),
            'shop_address'=>input('shop_address'),
            'longitude'=>input('longitude',0),
            'latitude'=>input('latitude',0),
            'summary'=>input('summary'),
            'zoom'=>input('zoom'),
            'mobile'=>input('mobile'),
            'cover_image'=>input('cover_image'),
            'logo'=>input('logo'),
            'bizhours_start'=>input('bizhours_start'),//营业时间开始
            'bizhours_end'=>input('bizhours_end'),//营业时间结束
            'flag_lock'=>input('flag_lock'),
            'aps_price' => input('aps_price'),
            'is_recommended'=>input('is_recommended')
        );
        return $this->logic->update_data($id,$param);
    }


    function delete()
    {
        $id=input('id');
        return $this->logic->delete_data($id);
    }
}
